#!/bin/sh
apps=$(pwd)
#clean up previous database
sudo rm -rf /etc/OpenBTS
sudo rm -rf /var/lib/asterisk/sqlite3dir
rm -f ${apps}/smqueue
rm -f ${apps}/sipauthserve


#link OpenBTS, smqueue, sipauthserve to /bin 
ln -s $apps/../../../smqueue/trunk/smqueue/smqueue ${apps}/smqueue
ln -s $apps/../../../subscriberRegistry/trunk/sipauthserve ${apps}/sipauthserve

sudo mkdir /etc/OpenBTS
#global gsm configuration
echo .quit|sudo sqlite3  -init ./GSM.config.sql /etc/OpenBTS/OpenBTS.db
subscriberdir=../../../subscriberRegistry/trunk
sudo mkdir /var/lib/asterisk/sqlite3dir
#subscriber confi
echo .quit|sudo sqlite3 -init $subscriberdir/configFiles/subscriberRegistryInit.sql /var/lib/asterisk/sqlite3dir/sqlite3.db
#To camp phones, run sipauthserve
echo .quit|sudo sqlite3 -init $subscriberdir/sipauthserve.example.sql   /etc/OpenBTS/sipauthserve.db
#sms queue configure
smqueuedir=../../../smqueue/trunk/smqueue
echo .quit|sudo sqlite3 -init $smqueuedir/smqueue.example.sql /etc/OpenBTS/smqueue.db
exit 0
